package com.dynamic.mybatis.demo.generator;


import com.mysql.cj.jdbc.MysqlDataSource;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;

/**
 * @Description
 * @Author xs
 * @Date 2023/4/13 17:55
 */
public class GeneratorTest {
    public static void main(String[] args) throws SQLException {
        MysqlDataSource dataSource = new MysqlDataSource();
        dataSource.setURL("jdbc:mysql://localhost:3306/boot-plate?useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT&tinyInt1isBit=false");
        dataSource.setUser("root");
        dataSource.setPassword("root");

        try (Connection connection =  dataSource.getConnection()){

           ResultSet rs =  connection.getMetaData().getColumns(connection.getCatalog(),connection.getSchema(),"test","%");
           ResultSetMetaData  rsm =  rs.getMetaData();
           int count =  rsm.getColumnCount();
           for(int i = 1 ; i <= count ; i++){
               String columnName = rsm.getColumnName(i);
               System.out.println(columnName);
               System.out.println(rs.getString(columnName));
           }
           rs.close();

        }


 /*       DynamicMybatisGenerator generator = new DynamicMybatisGenerator();
        String test = "test";
        List<String> tableNames = Stream.of("mapped_statement").collect(Collectors.toList());
        List<MapperMethod> mapperMethods = Stream.of(MapperMethod.selectList,MapperMethod.insert).collect(Collectors.toList());
        List<DynamicTable> tables =  generator.generate(test,tableNames,dataSource,mapperMethods);

        for(DynamicTable table : tables){

            System.out.println(table.getMappedStatement());
        }*/
    }
}